package com.zys.exercise;

public class text1 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8};
        int[]arr2=copyArr(arr,2,5);
        printArr(arr);
        System.out.println();
        printArr(arr2);

    }

    public static int[] copyArr(int[] arr, int from, int to) {
        int[] copyarr = new int[to - from];
        int j=0;

        for(int i=from;i<to;i++){
            copyarr[j]=arr[i];
            j++;
        }
        return copyarr;
    }
    public static void printArr(int[]arr){
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }

}
